{include file="header/index" /}
<meta charset="UTF-8">
<link rel="stylesheet" href="__CSS__/styleTwo.css" />
<style>
    #MenuName {
		color: #333333;
		font-size: 18px;
		font-family: "微软雅黑";
		line-height: 50px;
		/*color: #1cafff;*/
		font-weight: bold;
        margin-right: 30px;
	}

	.Authority {
		background: #fff;
		/*padding: 10px 15px;
        border-bottom: 1px solid #dcdcdc;*/
		height: 50px;
		margin-bottom: 10px;
		line-height: 50px;
	}

	.Authority i {
		float: left;
		margin-top: 14px;
		font-size: 22px;
		margin-right: 15px;
		color: #1cafff;
	}
	/*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/

	 ::-webkit-scrollbar {
		width: 0px;
		height: 16px;
		background-color: #F5F5F5;
	}
	/*定义滚动条轨道 内阴影+圆角*/

	 ::-webkit-scrollbar-track {
		-webkit-box-shadow: inset 0 0 0px rgba(242, 242, 242, 0);
		border-radius: 10px;
		background-color: #F5F5F5;
	}
	/*定义滑块 内阴影+圆角*/

	 ::-webkit-scrollbar-thumb {
		border-radius: 10px;
		-webkit-box-shadow: inset 0 0 0px rgba(242, 242, 242, 0);
		background-color: #d1d1d1;
	}

	.whitebg {
		padding-top: 10px;
	}
	.red-notice{
		display: none;
	    width: 20px !important;
	    height: 20px !important;
	    line-height: 20px;
	    text-align: center;
	    /* padding: 5px; */
	    border-radius: 50%;
	    background-color: #e9212a !important;
	    color: #FFF !important;

	}
	#all-order{
		display: inline-block !important;
	}
    /* 三级菜单栏 */

    .Authority>ul>li {
        margin-left: 10px;
        margin-right: 10px;
        cursor: pointer;
    }
    .Authority .current>a {
    /* color: #1cafff; */
        background: #1cafff;
        height: 34px;
        line-height: 34px;
        display: inline-block;
        padding: 0 15px;
        border-radius: 9px;
        color: #fff;
    }
    .Authority > ul > li > a {
        color: rgb(51, 51, 51);
        font-size: 16px;
        font-family: 微软雅黑;
    }

</style>

<body>
    <input type="hidden" value="" id="gcry">
    <input type="hidden" value="" id="gstatus">
    <input type="hidden" value="" id="assigned">
    <input type="hidden" value="" id="work_order_type">
    <input type="hidden" value="" id="work_order_status">
    <input type="hidden" value="" id="startUpdateTime">
    <div>
        <ul class="layui-nav cover_layui_ns" lay-filter="">
            <li class="layui-nav-item">
                <a class="navbar-brand navbar-logo" href="javascript:void(0)">
				<img src="/static/images/logo.png" onerror="this.src='__IMG__/logo.png'" style="width:100px;height: 40px">
			</a>
            </li>
            <li class="layui-nav-item">
                <a href="{:url('index/index')}" onclick="showMenu(this,333)">数据台</a>
            </li>
            <?php if(empty(!$menu)){?>
            {foreach $menu as $key => $val}
            {if condition="$val['url'] eq '#'"}
            <li class="layui-nav-item"><a href="{$val['url']}">{$val['url']}</a></li>
            {else /}
            <li class="layui-nav-item ">
                <a href="javascript:;" id="a{$val.id}" data-pid="{$val.id}" onclick="showMenu(this,{$val.id})" data-css="{$val.css}">{$val.title}</a>
                <?php if(empty(!$val['child'])){?>
                <dl class="layui-nav-child cover_layui_n_c">
                    <!-- 二级菜单 -->
                    {foreach $val['child'] as $cKey => $cVal}
                    <dd>
                        <a class="cover_new_ashow" target="myFrameName"  href="/{$cVal.url}" id="a{$cVal.id}" data-pid="{$cVal.id}" onclick="showMenu(this,{$cVal.id})">
	                	{$cVal.title}
	                </a>
                    </dd>
                    {/foreach}
                </dl>
                <?php } ?>
            </li>
            {/if}
            {/foreach}
            <?php }?>
              <li class="layui-nav-item rigth_item">
			    <a href="javascript:void(0)">{$username} </a>
			    <dl class="layui-nav-child">
			      {if condition="$is_admin eq 1"}
			      	<dd><a href="{:url('Authgroup/index')}" target="myFrameName">权限分配</a></dd>
			      {/if}
			      <dd><a href="javascript:void(0)"  onclick="loginOut();">退出</a></dd>
			    </dl>
			  </li>
        </ul>
    </div>
    <div class="contentBox Authority">
        <i class="glyphicon glyphicon-user" id="show_class"></i>
        <h2 class="layui-inline" id="MenuName">欢迎你【{$username}】</h2>
        <ul class="layui-inline" style="margin:0px" id="MenuShowList">
        </ul>
    </div>
    <div class="content" id="overflow">
        <iframe id="mainFrame" name="myFrameName" src="{:url('Index/doIndex')}" frameborder="0" scrolling="no" style=" width: 100%; "></iframe>
    </div>
    <!-- <div class="indexFooter">
        <div class="footer-left">Copyright © 2019 重庆亚特蓝电器有限责任公司 渝ICP备18001386号-1</div>
        <div class="footer-mid">Emal：2499082336@qq.com</div>
        <div class="footer-right">TEL：023-89883333</div>
    </div> -->
    <script type="text/javascript">
    var element = layui.element;
    element.render();

    $(document).ready(function() {
        //document.getElementById("mainFrame").style.height = "0px";//最好设置为minHeight
        console.log($(window).height())
        if ($(".Authority").is(":hidden")) {
            var height = $(window).height() - 132;
            startInit('mainFrame', height);
            $(".content").css("height", height)
            console.info(1)
        } else {
            var height = $(window).height() - 132;
            startInit('mainFrame', height);
            $(".content").css("height", height);
            console.info(2)
        }
        web();
    });

    // 获取iframe子页面下的导航栏,并设置定位
    $("#overflow").scrollTop(0);
    $("#overflow").scroll(function() {
        if ($($('#mainFrame').prop('contentWindow').document).find(".fix").html() != undefined) {
            $($('#mainFrame').prop('contentWindow').document).find(".fix").css({
                "top": $("#overflow").scrollTop(),
            });
        }
    });

    // ==================================
    $('.navigation_hide').click(function() {
        $('.Authority').hide();
    })


    function current(obj) {
        $('#gcry').val('')
        $('#gstatus').val('')
        $(obj).parent("li").addClass("current");
        $(obj).parent("li").siblings().removeClass("current");
    }

    $(".nav-left>li").click(function() {

        $(this).addClass("active");
        $(this).siblings().removeClass("active");
        $(this).parent(".nav-left").next(".nav-right").find("li").removeClass("active");
    })
    $(".nav-right>li").click(function() {
        // $('.Authority').hide();
        $(this).addClass("active");
        $(this).siblings().removeClass("active");
        $(this).parent(".nav-right").prevAll(".nav-left").find("li").removeClass("active");
    })

    /**
     * 查询二级菜单栏
     */
    function showMenu(obj, id) {
        console.log('id', id)

        $.post("{:url('Index/MenuList')}", {
            id: id
        }, function(e) {
            if (e.code == 0) {
                layer.msg(e.msg, {
                    icon: 0,
                    shade: 0.1
                });
                return false;
            }
            console.log('e',e)
            $('.Authority').show();
            $("#MenuName").text($(obj).text());
            $("#show_class").removeClass();
            $("#show_class").addClass($(obj).attr('data-css'));
            var str = '';
            $("#MenuShowList").html('');
            $.each(e.data, function(key, val) {
                str += '<li class="layui-inline">';
                str += '<a href="/' + val.url + '" target="myFrameName" onclick="current(this)">' + val.title + '</a>';
                str += '</li>';

            })
            console.log('str',str)
            $("#MenuShowList").html(str);
            $("#MenuShowList>li").eq(0).addClass("current");
        }, 'json');

    }
    function loginOut() {
        $.post("{:url('Login/loginOut')}", {}, function(e) {
            layer.msg(e.msg, {
                icon: 6,
                time: 2000
            }, function() {
                sessionStorage.clear();
                window.location.href = e.data;
            });
        })
    }


    //websocket操作
    function web(msg) {
        return false;
        exampleSocket = new WebSocket("{$socket_url}");
        console.log("{$socket_url}");
        //console.log(exampleSocket.readyState);
        exampleSocket.onopen = function(event) {
            console.log(exampleSocket.readyState, "1111111");
            var data = {};
            data.controller_name = "Websocket",
                data.method_name = "bind_uid";
            data.data = 'youheone_admin';
            data = JSON.stringify(data);
            //console.log(data);
            exampleSocket.send(data);
            setInterval(function() {
                var data = {};
                data.controller_name = "Websocket",
                    data.method_name = "ping";
                data.data = 'youheone_admin';
                data = JSON.stringify(data);
                exampleSocket.send(data);
            }, 20000);

            if (msg) {
                send();
            }
        };

        exampleSocket.onmessage = function(event) {
            var data = JSON.parse(event.data);
            if (data.type == 1) {
                $("#new-order").show();
                $("#new-order").css('display', 'inline-block');
                var num = parseInt($("#new-order").text()) + 1;
                $("#new-order").text(num);
            } else if (data.type == 2) {
                $("#new-work-order").show();
                $("#new-work-order").css('display', 'inline-block');
                var num = parseInt($("#new-work-order").text()) + 1;
                $("#new-work-order").text(num);
            }

            var new_order = parseInt($("#new-order").text());
            var new_work_order = parseInt($("#new-work-order").text());
            var all_num = new_order + new_work_order;
            $("#all-order").text(all_num);
        }
        exampleSocket.onclose = function(res) {
            console.log("关闭", res)
        }
        exampleSocket.onerror = function(res) {
            console.log("错误", res)
        }

    }

    function send() {
        console.log(exampleSocket.readyState)
        if (exampleSocket.readyState != 1) {
            console.log('服务器走丢了~');
            web('1');
        } else {
            var text = {};
            text.controller_name = "Websocket",
                text.method_name = "efficiency_test2";
            text.data = document.getElementById('content').value;
            text = JSON.stringify(text);
            exampleSocket.send(text);
        }

    }
    </script>
</body>

</html>
